//
//  HYCSecondRecommendCell.m
//  FamilyTravel
//
//  Created by dllo on 15/10/22.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "HYCSecondRecommendCell.h"
#import "HYCSecondRecommendModel.h"
#import <UIImageView+WebCache.h>

#define WIDTH self.contentView.frame.size.width
#define HEIFGT self.contentView.frame.size.height

@implementation HYCSecondRecommendCell





- (void)dealloc {
    [_comlabel release];
    [_hotImageView release];
    [_comImageView release];
    [_readImageView release];
    [_hotlabel release];
    [_hotView release];
    [_readLabel release];
    [_workLabel release];
    
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}
- (void)createCell{
    
    self.hotView = [[UIView alloc] init];
    [self.contentView addSubview:self.hotView];
    [_hotView release];
    
    self.hotImageView = [[UIImageView alloc] init];
    [self.hotView addSubview:self.hotImageView];
    self.hotImageView.layer.borderWidth = 1;
    self.hotImageView.layer.cornerRadius = 10;
    self.hotImageView.layer.masksToBounds = YES;
    [_hotImageView release];
//    self.hotImageView.backgroundColor = [UIColor redColor];
    
    self.comImageView = [[UIImageView alloc]init];
    [self.hotView addSubview:self.comImageView];
    [_comImageView release];
//    self.comImageView.backgroundColor = [UIColor redColor];
    
    self.readImageView = [[UIImageView alloc] init];
    [self.hotView addSubview:self.readImageView];
    [_readImageView release];
//    self.readImageView.backgroundColor = [UIColor redColor];
    
    self.hotlabel = [[UILabel alloc] init];
    [self.hotView addSubview:self.hotlabel];
    self.hotlabel.font = [UIFont systemFontOfSize:14];
    self.hotlabel.numberOfLines = 0;
    [_hotlabel release];
//    self.hotlabel.backgroundColor = [UIColor redColor];/
    
    self.comlabel = [[UILabel alloc] init];
    [self.hotView addSubview:self.comlabel];
    self.comlabel.font = [UIFont systemFontOfSize:12];
    [_comlabel release];
//    self.comlabel.backgroundColor = [UIColor redColor];
    
    self.readLabel = [[UILabel alloc] init];
    [self.hotView addSubview:self.readLabel];
    self.readLabel.font = [UIFont systemFontOfSize:12];
    [_readLabel release];
//    self.readLabel.backgroundColor = [UIColor yellowColor];
    
    self.workLabel = [[UILabel alloc] init];
    [self.hotView addSubview:self.workLabel];
    self.workLabel.font = [UIFont systemFontOfSize:12];
    [_workLabel release];
//    self.workLabel.backgroundColor = [UIColor yellowColor];
    
}
- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.hotView.frame = CGRectMake(5 , 0, WIDTH, HEIFGT);
    self.hotImageView.frame = CGRectMake(5, HEIFGT / 15, WIDTH / 2.6785, HEIFGT / 1.1538);
    self.readImageView.frame = CGRectMake(WIDTH / 2.48, HEIFGT / 1.3636, 20, 20);
    self.hotlabel.frame = CGRectMake(WIDTH / 2.343, 15, WIDTH / 1.875, HEIFGT / 1.6666);
    self.workLabel.frame = CGRectMake(WIDTH / 1.293, HEIFGT / 1.3636, WIDTH / 5.4, 25);
    self.readLabel.frame = CGRectMake(WIDTH / 2.1, HEIFGT / 1.3636, WIDTH / 9.2, 20);
    self.comImageView.frame = CGRectMake(WIDTH / 1.66, HEIFGT / 1.3636, 20, 20);
    self.comlabel.frame = CGRectMake(WIDTH / 1.485, HEIFGT / 1.3636, 30, 20);

}
#pragma mark -  Setter Method
- (void)setModel:(HYCSecondRecommendModel *)model {
    if (_model != model) {
        [_model release];
        _model = [model retain];

        _hotlabel.text = _model.title;
        
        _readLabel.text = [_model.views stringValue];
        
        _workLabel.text = _model.username;
        _comlabel.text = _model.replys;
        
        _readImageView.image = [UIImage imageNamed:@"read.png"];
        
        _comImageView.image = [UIImage imageNamed:@"com.png"];
        
        [_hotImageView sd_setImageWithURL:[NSURL URLWithString:_model.photo]placeholderImage:[UIImage imageNamed:@"zw.png"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
            
        }];
        
    }
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
